package com.mogu.blogs.controller;

import com.mogu.blogs.pojo.BlogSort;
import com.mogu.blogs.pojo.BlogTitle;
import com.mogu.blogs.service.SortService;
import com.mogu.entity.TBlog;
import com.mogu.entity.TBlogSort;
import io.swagger.annotations.ApiOperation;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.UUID;

/**
 * Created by 45795 on 2020/6/15.
 */
@RestController
@RequestMapping(value = "/sort")
public class SortController {

    @Autowired
    SortService sortService;

    /*
    * 显示所有分类
    * */
    @RequestMapping(value = "/listSort",method = RequestMethod.GET)
    public List<TBlogSort> findList(){
        return sortService.findAll();
    }
    /*
    * 分类点击数+1
    * */
    @RequestMapping(value = "/addClick",method = RequestMethod.GET)
    public void addClick(String uid){
        sortService.addClick(uid);
    }
    /*
    *通过分类查找所有博客
    * */
    @RequestMapping(value = "/findBlogBySort",method = RequestMethod.GET)
    public List<BlogTitle> findBlogBySort(String uid){
        return sortService.findBlogBySort(uid);
    }
    @GetMapping("/findBlogBySortUid/{uid}")
    public List<TBlog> findBlogBySortUid(@PathVariable String uid){
        return this.sortService.findBlogBySortUid(uid);
    }


    /**
     * 根据博客表的博客分类id查询blog分类前台页面需要展示的视图集合
     * @param blogSortUid
     * @return
     */
    @ApiOperation(value = "通过blogSortUid查询分类页面内容" , notes = "通过blogSortUid查询分类页面内容")
    @GetMapping("/findBlogSortByBlogSortUid/{blogSortUid}")
    public List<BlogSort> findBlogSortByBlogSortUid(@PathVariable String blogSortUid){
        return this.sortService.findBlogSortByBlogSortUid(blogSortUid);
    }



}
